﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LibRadiant.IO;
using LibRadiant.Main;

namespace TestPlatform
{
    public partial class MainFrame : Form
    {
        private IOManager IOManager
        {
            get { return mRenderingPanel.RenderCore.IOManager; }
        }

        private Camera Camera
        {
            get { return mRenderingPanel.RenderCore.Camera; }
        }

        internal MainFrame()
        {
            InitializeComponent();

            IOManager.KeyUp += new LibRadiant.IO.KeyboardEvent(IOManager_KeyUp);
            IOManager.KeyDown += new LibRadiant.IO.KeyboardEvent(IOManager_KeyDown);
            IOManager.MouseUp += new LibRadiant.IO.MouseEvent(IOManager_MouseUp);
            IOManager.MouseDown += new LibRadiant.IO.MouseEvent(IOManager_MouseDown);
            IOManager.MouseMove += new LibRadiant.IO.MouseEvent(IOManager_MouseMove);
        }


        //晚一點在做一個buffer input
        void IOManager_MouseMove(MouseEventArgs inArg)
        {
            
        }

        void IOManager_MouseDown(MouseEventArgs inArg)
        {
        }

        void IOManager_MouseUp(MouseEventArgs inArg)
        {
        }

        void IOManager_KeyDown(KeyEventArgs inArg)
        {
            switch(inArg.KeyCode)
            {
                case Keys.W:
                    Camera.Position += Camera.At;
                    break;
                case Keys.S:
                    Camera.Position -= Camera.At;
                    break;
                case Keys.A:
                    Camera.Position += Camera.Left;
                    break;
                case Keys.D:
                    Camera.Position -= Camera.Left;
                    break;
            }
        }

        void IOManager_KeyUp(KeyEventArgs inArg)
        {
        }

        internal void DoUpdate()
        {
            mRenderingPanel.UpdateRender();
        }

    }
}
